function getProducts(callBackFunction) {
	var requestObject = webAPIRequestObject(0, "getProducts", []);
	runRequest(requestObject, callBackFunction);
}
function getProductByID(id, callBackFunction) {
	var requestObject = webAPIRequestObject(0, "getProductByID", [id]);
	runRequest(requestObject, callBackFunction);
}
function getProductByName(name, callBackFunction) {
	var requestObject = webAPIRequestObject(0, "getProductByName", [name]);
	runRequest(requestObject, callBackFunction);
}
function getProductByDescription(description, callBackFunction) {
	var requestObject = webAPIRequestObject(0, "getProductByDescription", [description]);
	runRequest(requestObject, callBackFunction);
}
function getProductByUPC(upc, callBackFunction) {
	var requestObject = webAPIRequestObject(0, "getProductByUPC", [upc]);
	runRequest(requestObject, callBackFunction);
}
function getProductByGroupID(id, callBackFunction) {
	var requestObject = webAPIRequestObject(0, "getProductByGroupID", [id]);
	runRequest(requestObject, callBackFunction);
}
function getGroups(callBackFunction) {
	var requestObject = webAPIRequestObject(0, "getGroups", []);
	runRequest(requestObject, callBackFunction);
}
function getGroupByID(id, callBackFunction) {
	var requestObject = webAPIRequestObject(0, "getGroupByID", [id]);
	runRequest(requestObject, callBackFunction);
}
function getGroupBYName(name, callBackFunction) {
	var requestObject = webAPIRequestObject(0, "getGroupBYName", [name]);
	runRequest(requestObject, callBackFunction);
}
function getBrands(callBackFunction) {
	var requestObject = webAPIRequestObject(0, "getBrands", []);
	runRequest(requestObject, callBackFunction);
}
function getBrandByID(id, callBackFunction) {
	var requestObject = webAPIRequestObject(0, "getBrandByID", [id]);
	runRequest(requestObject, callBackFunction);
}
function getBrandByName(name, callBackFunction) {
	var requestObject = webAPIRequestObject(0, "getBrandByName", [name]);
	runRequest(requestObject, callBackFunction);
}

function addProduct(name, description, upc, size, sizeId, brandId, groupId, callBackFunction) {
	var requestObject = webAPIRequestObject(0, "addProduct", [name, description, upc, size, sizeId, brandId, groupId]);
	runRequest(requestObject, callBackFunction);
}
function addMutiplicator(upc, multiplicator, productId, callBackFunction) {
	var requestObject = webAPIRequestObject(0, "addMutiplicator", [upc, multiplicator, productId]);
	runRequest(requestObject, callBackFunction);
}
function addGroup(name, description, callBackFunction) {
	var requestObject = webAPIRequestObject(0, "addGroup", [name, description]);
	runRequest(requestObject, callBackFunction);
}
function addBrand(name, callBackFunction) {
	var requestObject = webAPIRequestObject(0, "addBrand", [name]);
	runRequest(requestObject, callBackFunction);
}

function editProduct(id, name, description, upc, size, sizeId, brandId, groupId, callBackFunction) {
	var requestObject = webAPIRequestObject(0, "editProduct", [id, name, description, upc, size, sizeId, brandId, groupId]);
	runRequest(requestObject, callBackFunction);
}
function editMultiplicator(id, upc, multiplicator, productId, callBackFunction) {
	var requestObject = webAPIRequestObject(0, "editMultiplicator", [id, upc, multiplicator, productId]);
	runRequest(requestObject, callBackFunction);
}
function editGroup(id, name, description, parentId, callBackFunction) {
	var requestObject = webAPIRequestObject(0, "editGroup", [id, name, description, parentId]);
	runRequest(requestObject, callBackFunction);
}
function editBrand(id, name, callBackFunction) {
	var requestObject = webAPIRequestObject(0, "editBrand", [id, name]);
	runRequest(requestObject, callBackFunction);
}

function delProductByID(id, callBackFunction) {
	var requestObject = webAPIRequestObject(0, "delProductByID", [id]);
	runRequest(requestObject, callBackFunction);
}
function delProductByUPC(upc, callBackFunction) {
	var requestObject = webAPIRequestObject(0, "delProductByUPC", [upc]);
	runRequest(requestObject, callBackFunction);
}
function delMultiplicatorByID(id, callBackFunction) {
	var requestObject = webAPIRequestObject(0, "delMultiplicatorByID", [id]);
	runRequest(requestObject, callBackFunction);
}
function delMultiplicatorByUPC(upc, callBackFunction) {
	var requestObject = webAPIRequestObject(0, "delMultiplicatorByUPC", [upc]);
	runRequest(requestObject, callBackFunction);
}
function delGroupByID(id, callBackFunction) {
	var requestObject = webAPIRequestObject(0, "delGroupByID", [id]);
	runRequest(requestObject, callBackFunction);
}
function delGroupByUPC(upc, callBackFunction) {
	var requestObject = webAPIRequestObject(0, "delGroupByUPC", [upc]);
	runRequest(requestObject, callBackFunction);
}
function delBrandByID(id, callBackFunction) {
	var requestObject = webAPIRequestObject(0, "delBrandByID", [id]);
	runRequest(requestObject, callBackFunction);
}
function delBrandByUPC(upc, callBackFunction) {
	var requestObject = webAPIRequestObject(0, "delBrandByUPC", [upc]);
	runRequest(requestObject, callBackFunction);
}

function moreProductByID(id, qty, callBackFunction) {
	var requestObject = webAPIRequestObject(0, "moreProductByID", [id, qty]);
	runRequest(requestObject, callBackFunction);
}
function moreProductByUPC(upc, qty, callBackFunction) {
	var requestObject = webAPIRequestObject(0, "moreProductByUPC", [upc, qty]);
	runRequest(requestObject, callBackFunction);
}

function lessProductByID(id, qty, callBackFunction) {
	var requestObject = webAPIRequestObject(0, "lessProductByID", [id, qty]);
	runRequest(requestObject, callBackFunction);
}
function lessProductByUPC(upc, qty, callBackFunction) {
	var requestObject = webAPIRequestObject(0, "lessProductByUPC", [upc, qty]);
	runRequest(requestObject, callBackFunction);
}



/* System function */
function runRequest(requestObject, callBackFunction) {
	requestAJAXAsyc("webapi.php?x="+Math.random(), requestObject, callBackFunction);
}
function webAPIRequestObject(id, functionName, arguments) {
	
	var output = '<?xml version="1.0" encoding="UTF-8" ?>';
		output = output + '<request id="'+id+'">';
		output = output + '<function>'+functionName+'</function>';
		output = output + '<arguments>';
		
		for (x in arguments)
			output = output + '<argument name="arg' + x + '">' + arguments[x] + '</argument>';
		
		output = output + '</arguments>';
		output = output + '</request>';
	
	return output;
	
}
